package cn.demoncat.util.lang.entity;

import cn.demoncat.util.lang.constant.LongConstant;
import cn.demoncat.util.lang.constant.StatusConstant;
import lombok.Data;

/**
 * 状态和数量
 *
 * @author 延晓磊
 * @since 2022年01月13日
 */
@Data
public class StatusCount {

    /**
     * 失败
     */
    public static final StatusCount ERROR = error();

    /**
     * 空
     */
    public static final StatusCount EMPTY = empty();

    /**
     * 状态
     */
    private String status;
    /**
     * 计数
     */
    private Long count;

    /**
     * 失败
     *
     * @return {status:0,count:0}
     */
    public static StatusCount error(){
        StatusCount data = new StatusCount();
        data.setStatus(StatusConstant.Common.NO);
        data.setCount(LongConstant.N0);
        return data;
    }

    /**
     * 空
     *
     * @return {status:1,count:0}
     */
    public static StatusCount empty(){
        StatusCount data = new StatusCount();
        data.setStatus(StatusConstant.Common.YES);
        data.setCount(LongConstant.N0);
        return data;
    }

    /**
     * 成功
     *
     * @return {status:1,count:0}
     */
    public static StatusCount success(long count){
        StatusCount data = new StatusCount();
        data.setStatus(StatusConstant.Common.YES);
        data.setCount(count);
        return data;
    }
}
